Skip to content

feat(metrics): emit conserver.ingress_list.length observable gauge - #173

Merged
pavanputhra merged 1 commit into
mainfrom
feat/con-565-ingress-length-gauge
May 20, 2026
Merged

pavanputhra merged 1 commit into
mainfrom
feat/con-565-ingress-length-gauge

Conversation

@pavanputhra

Copy link
Copy Markdown
Contributor

Summary

Add an OpenTelemetry observable gauge conserver.ingress_list.length that samples Redis LLEN for every configured ingress list and its derived DLQ. Each observation carries:

attribute value
ingress_list configured name (e.g. "transcribe") — matches the existing conserver.main_loop.count_vcons_received{ingress_list=…} counter dimension
kind "ingress" for the live queue, "dlq" for the derived dead-letter queue

Splitting kind into its own attribute (rather than baking DLQ: into the value) lets queries filter live vs dead-letter cleanly: conserver.ingress_list.length{kind="dlq"} > 0 instead of regex-matching ^DLQ: in a label value.

The callback re-reads chain config on every export tick, so new ingress lists begin emitting series automatically — no worker restart required.

Pairs with the conserver.dlq.count counter from #171: counter records the event of moving a vCon to DLQ; gauge records the state of how many are sitting there right now.

Implementation

  • New common/lib/queue_metrics.py owns the callback construction (one observation per (ingress_list, kind) combination).
  • New register_observable_gauge() helper in common/lib/metrics.py keeps OTel SDK plumbing in one place and matches the existing increment_counter / record_histogram lazy-init pattern.
  • worker_loop() calls register_ingress_list_length_gauge() once per worker process, immediately after the Redis client + VconQueue are initialized.
  • With N replicas you get N identical series per dimension combination; query-time aggregation (max by (ingress_list, kind)) collapses them.
  • Individual LLEN failures (transient Redis errors) skip that series only — the export tick still publishes the series that succeeded.

Test plan

  • New common/tests/test_queue_metrics.py covers the callback in isolation (no OTel SDK):
    • empty config → empty observations
    • dedup + sort of ingress lists across multiple chains
    • config-read failure → no series, no exception (degraded mode)
    • one observation per (ingress_list, kind) with correct values
    • ingress_list attribute value is the bare configured name for BOTH the live and DLQ observations
    • individual LLEN failure skips that series, others still emit
  • Existing common/tests/test_dlq_expiry.py, test_queue_dlq_counter.py, test_parallel_processing.py still pass
  • Manual verification on a running deployment: roll the new image, confirm conserver.ingress_list.length appears with the expected dimensions

🤖 Generated with Claude Code

Add an OpenTelemetry observable gauge that samples Redis LLEN for every
configured ingress list and its derived DLQ. Each observation carries:

  ingress_list = configured name as in chains.<chain>.ingress_lists
                 (e.g. "transcribe")
  kind         = "ingress" | "dlq"

Splitting kind into its own attribute (rather than baking "DLQ:" into the
value) lets monitoring queries filter live vs dead-letter cleanly:
queue_length{kind="dlq"} > 0 instead of regex-matching "^DLQ:".

The callback re-reads chain config on every export tick, so new ingress
lists begin emitting series automatically without a worker restart. The
metric exists alongside the new conserver.dlq.count counter (#171): the
counter records DLQ-write events; the gauge records DLQ-occupancy snapshots.

Implementation:

* New common/lib/queue_metrics.py owns the callback construction.
* New register_observable_gauge() helper in common/lib/metrics.py keeps the
  OTel SDK plumbing in one place and matches the existing
  increment_counter / record_histogram lazy-init pattern.
* worker_loop() calls register_ingress_list_length_gauge() once per worker
  process. With N replicas you get N identical series per dimension;
  query-time aggregation (max by ingress_list, kind) collapses them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pavanputhra
pavanputhra merged commit 66f742b into main May 20, 2026
1 check passed
@pavanputhra
pavanputhra deleted the feat/con-565-ingress-length-gauge branch May 20, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant